package com.boe.common.util.freemark.base;


import lombok.*;
import com.boe.common.util.StringUtil;
import com.boe.common.util.freemark.P0Error;
import com.boe.common.util.freemark.BaseMethodModelFreemarker;
import freemarker.template.TemplateModelException;

import java.lang.reflect.Field;
import java.util.List;

public class FreemarkerBigCamelCase extends BaseMethodModelFreemarker {


    @Override
    public Object exec(List list) throws TemplateModelException {

        var paramValue = getFreemarkerParameter(list.get(0));

        if (paramValue instanceof Field) {
            return StringUtil.getBigCamelCase(((Field) paramValue).getName());
        } else if (paramValue instanceof String) {
            return StringUtil.getBigCamelCase((String) paramValue);
        }


        throw  new P0Error(paramValue);
    }
}